package com.jstyle.beatecg.view;

import android.content.Context;
import android.content.DialogInterface;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import com.jstyle.beatecg.R;
import com.jstyle.beatecg.adapter.WheelAdapter;
import com.jstyle.beatecg.util.ScreenUtils;
import com.jstyle.beatecg.view.widget.views.WheelView;
import java.util.List;
import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2018/5/4.
 */

public class FeedBackDialog extends JstyleDialog {
    @BindView(R.id.bt_dialog_adduser_cancel)
    Button btDialogAdduserCancel;
    @BindView(R.id.bt_dialog_adduser_title)
    Button btDialogAdduserTitle;
    @BindView(R.id.bt_dialog_adduser_ok)
    Button btDialogAdduserOk;
    @BindView(R.id.wheelView_topic)
    WheelView wheelViewTopic;
    private List<String> topicList;
    private WheelAdapter wheelAdapter;

    public FeedBackDialog(@NonNull Context context) {
        super(context);
        init(context);
    }
    public FeedBackDialog(@NonNull Context context,List<String> topicList) {
        super(context);
        this.topicList=topicList;
        init(context);
    }

    public FeedBackDialog(@NonNull Context context,List<String> topicList, int themeResId) {
        super(context, themeResId);
        this.topicList=topicList;
        init(context);
    }
    public  void wheelViewTopicindex(int index,boolean animated){
        wheelViewTopic.setCurrentItem(index,animated);
    }
    protected FeedBackDialog(@NonNull Context context, boolean cancelable, @Nullable DialogInterface.OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }
    private void init(Context context) {
        initStyle(R.style.dialog_bottom_animstyle);
        initWidth(ScreenUtils.getScreenWidth(context));
        initGravity(Gravity.BOTTOM);
        initData();
    }
    private void initData() {
        wheelAdapter = new WheelAdapter(getContext(), topicList, 0, 24, 14);
        wheelViewTopic.setViewAdapter(wheelAdapter);
    }

    public void   setListData(List<String> list) {
        this.topicList=list;
    }
    @Override
    protected void setContentView() {
        setContentView(R.layout.dialog_feednack_topic);
    }

    private static final String TAG = "FeedBackDialog";
    @OnClick({R.id.bt_dialog_adduser_cancel, R.id.bt_dialog_adduser_ok})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.bt_dialog_adduser_cancel:
                dismiss();
                break;
            case R.id.bt_dialog_adduser_ok:
              //  Log.i(TAG, "onViewClicked: "+wheelViewTopic.getCurrentItem());
               sendData(wheelViewTopic.getCurrentItem());
                dismiss();
                break;
        }
    }
}
